package com.shangye.core;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class SouthWindApplication {

    private ServerSocket serverSocket;

    public SouthWindApplication(){
        try {
            System.out.println("正在启动服务器...");
            serverSocket = new ServerSocket(8088);
            System.out.println("服务器启动完毕！");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void start(){

        try {
            System.out.println("正在等待客户端连接...");
            Socket socket = serverSocket.accept();
            System.out.println("一个客户端连接上了服务器！");
            ClientHandler handler = new ClientHandler(socket);
            new Thread(handler).start();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new SouthWindApplication().start();
    }

}
